<?php

// po potvrdzovacom emaily treba spravit presmerovanie na stranku s prihlasenim
// styl treba niekde korektne presunut

$enterAtLeast = "Zadajte počet znakov najmenej {0}";
$enterName = "Zadajte krstné meno";
$enterSurname = "Zadajte priezvisko";
$providePassword = "Zadajte heslo";
$repeatPassword = "Zopakujte heslo";
$theSamePassword = "Zadajte to isté heslo ako predošlé";
$enterValidEmail = "Zadajte platnú mailovú adresu";
$emailAddressUsed = "Zadaná mailovú adresu už používa iný používateľ";
$sentToYourEmail = "Na vašu adresu bol zaslaný mail na potvrdenie registrácie.";

$firstnameStr = "Meno";
$lastnameStr = "Priezvisko";
$emailaddressStr = "Emailová adresa";
$passwordStr = "Heslo";
$confirmPasswordStr = "Potvrdiť heslo";
$sexStr = "Pohlavie";
$maleStr = "Muž";
$femaleStr = "Žena";
$mobilStr = "Mobil";
$submitStr = "Registrovať";

if (isEnglish())
{
    // rozvetvim si to tu na slovensku a anglicku cast a dorobim odosielanie
    $enterAtLeast = "Enter at least {0} characters";
    $enterName = "Enter your firstname";
    $enterSurname = "Enter your surname";
    $providePassword =  "Provide a password";
    $repeatPassword = "Repeat your password";
    $theSamePassword = "Enter the same password as above";
    $enterValidEmail = "Please enter a valid email address";
    $emailAddressUsed = "Email address is used by another user";
    $sentToYourEmail = "There was sent an email to your account to confirm registration.";

    $firstnameStr = "First name";
    $lastnameStr = "Last name";
    $emailaddressStr = "Email address";
    $passwordStr = "Password";
    $confirmPasswordStr = "Confirm Password";
    $sexStr = "Sex";
    $maleStr = "Male";
    $femaleStr = "Female";
    $mobilStr = "Mobil";
    $submitStr = "Register";
}


$scriptStr = "
     
<script type=\"text/javascript\">
$(document).ready(function() {
	// validate signup form on keyup and submit
	var validator = $(\"#registrationform\").validate({
		rules: 
        {
			name:
            {
				required: true,
				minlength: 2
			},

			surname:
            {
				required: true,
				minlength: 2
			},

			password: 
            {
				required: true,
				minlength: 5
			},
			password_confirm: 
            {
				required: true,
				minlength: 5,
				equalTo: \"#password\"
			},

			email: 
            {
				required: true,
				email: true,
				remote: \"./ajax/registrationvalidation.php\"
			}

		},
		messages: 
        {
			name: 
            {
                required:\"$enterName\",
                minlength:\"$enterAtLeast\"
            },

			surname:
            {
                required:\"$enterSurname\",
                minlength:\"$enterAtLeast\"
            },

			password: 
            {
				required: \"$providePassword\",
                minlength:\"$enterAtLeast\"
			},

			password_confirm: 
            {
				required: \"$repeatPassword\",
				minlength: jQuery.format(\"$enterAtLeast\"),
				equalTo: \"$theSamePassword\"
			},

			email: 
            {
				required: \"$enterValidEmail\",
				email: \"$enterValidEmail\", 
				remote: jQuery.format(\"{0} $emailAddressUsed\")
			}
		},
		// the errorPlacement has to take the table layout into account
		//errorPlacement: function(error, element) {
		//	if ( element.is(\":radio\") )
		//		error.appendTo( element.parent().next().next() );
		//	else if ( element.is(\":checkbox\") )
		//		error.appendTo ( element.next() );
		//	else
		//		error.appendTo( element.parent().next() );
		// },

		// specifying a submitHandler prevents the default submit, good for the demo
		//submitHandler: function() {
		//	alert('submitted!');
        //    form.submit();
		//},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html('&nbsp;').addClass('checked');
		}
	});

});
</script>
";
 
 $formStr = "
     <form id=\"registrationform\" method=\"post\" action=\"index.php?siteName=./applogic/acceptregistration.php\">
	  		  <table class=\"formCentered\">
	  		  <tr>
	  		  	<td class=\"label\"><label id=\"lname\" for=\"name\">$firstnameStr</label></td>
	  		  	<td class=\"field\"><input id=\"name\" name=\"name\" type=\"text\" value=\"\" maxlength=\"100\" ></td>
	  		  	<td class=\"status\"></td>
	  		  </tr>
	  		  <tr>
	  			<td class=\"label\"><label id=\"lsurname\" for=\"surname\">$lastnameStr</label></td>
	  			<td class=\"field\"><input id=\"surname\" name=\"surname\" type=\"text\" value=\"\" maxlength=\"100\" ></td>
	  			<td class=\"status\"></td>
	  		  </tr>
	  		  <tr>
	  			<td class=\"label\"><label id=\"lemail\" for=\"email\">$emailaddressStr</label></td>
	  			<td class=\"field\"><input id=\"email\" name=\"email\" type=\"text\" value=\"\" maxlength=\"150\" ></td>
	  			<td class=\"status\"></td>
	  		  </tr>
	  		  <tr>
	  			<td class=\"label\"><label id=\"lpassword\" for=\"password\">$passwordStr</label></td>
	  			<td class=\"field\"><input id=\"password\" name=\"password\" type=\"password\" maxlength=\"50\" value=\"\" ></td>
	  			<td class=\"status\"></td>
	  		  </tr>
	  		  <tr>
	  			<td class=\"label\"><label id=\"lpassword_confirm\" for=\"password_confirm\">$confirmPasswordStr</label></td>
	  			<td class=\"field\"><input id=\"password_confirm\" name=\"password_confirm\" type=\"password\" maxlength=\"50\" value=\"\" ></td>
	  			<td class=\"status\"></td>
	  		  </tr>
              
              <tr>
	  			<td class=\"label\"><label id=\"lsex\">$sexStr</label></td>
	  			<td class=\"field\"> 
                <input type=\"radio\" name=\"sex\" value=\"1\" > $maleStr 
                <input type=\"radio\" name=\"sex\" value=\"2\" > $femaleStr 
                </td>
	  			<td class=\"status\"></td>
	  		  </tr>
              
              <tr>
	  			<td class=\"label\"><label id=\"lmobil\" for=\"mobil\">$mobilStr</label></td>
	  			<td class=\"field\"><input id=\"mobil\" name=\"mobil\" type=\"text\" value=\"\" maxlength=\"14\" ></td>
	  			<td class=\"status\"></td>
	  		  </tr>
              
              <tr>
              <td></td>
              <td><input type=\"submit\" name=\"\" value=\"$submitStr\" ></td>
              <td></td>
	  	      </tr>
	  	      </table>
              
              </form>
                ";
 
 echo( $scriptStr );
 echo( $formStr );
?>
